home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1993 / Internet Info CD-ROM (Walnut Creek) (1993).iso / networking / ip / ka9q / osrc.arc / NR4.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-13  |  1.2 KB  |  60 lines

  1. /* net/rom level 4 (transport) protocol implementation
  2.  * Dan Frank, W9NK
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include "global.h"
  7. #include "mbuf.h"
  8. #include "timer.h"
  9. #include "ax25.h"
  10. #include "lapb.h"
  11. #include "netrom.h"
  12. #include "nr4.h"
  13. #include <ctype.h>
  14.  
  15. void
  16. nr4input(hdr,bp)
  17. struct nr4hdr *hdr ;
  18. struct mbuf *bp ;
  19. {
  20.     struct nr4hdr rhdr ;
  21.     struct nr3hdr n3hdr ;
  22.     struct mbuf *n3b, *n4b ;
  23.  
  24.     /* For now, just reject connections.  We'll maybe get
  25.      * more clever later ...
  26.      */
  27.  
  28.     if (hdr->opcode == NR4OPCONRQ) {
  29.         /* Format a network header - source call will be filled
  30.          * in by nr_route()
  31.          */
  32.         n3hdr.dest = hdr->u.conreq.node ;    /* respond to node */
  33.         n3hdr.ttl = Nr_ttl ;
  34.  
  35.         /* Format a transport connect acknowledge header */
  36.         rhdr.opcode = NR4OPCONAK | NR4CHOKE ;    /* choke means reject */
  37.         rhdr.u.conack.yourindex = hdr->u.conreq.myindex ;
  38.         rhdr.u.conack.yourid = hdr->u.conreq.myid ;
  39.         rhdr.u.conack.myindex = 0 ;
  40.         rhdr.u.conack.myid = 0 ;
  41.         rhdr.u.conack.window = 0 ;
  42.  
  43.         if ((n3b = htonnr3(&n3hdr)) == NULLBUF) {
  44.             free_p(bp) ;
  45.             return ;
  46.         }
  47.  
  48.         if ((n4b = htonnr4(&rhdr)) == NULLBUF) {
  49.             free_p(n3b) ;
  50.             free_p(bp) ;
  51.             return ;
  52.         }
  53.  
  54.         append(&n3b,n4b) ;
  55.         nr_route(n3b,NULLAX25) ;
  56.     }
  57.  
  58.     free_p(bp) ;
  59. }
  60.